<%@ include file="/WEB-INF/views/include.jsp"%>
<div id="modal-deactive-user" class="modal hide fade">
		<div class="modal-header">
			<a href="#" class="close">&times;</a>
			<h3>Active User</h3>
		</div>
		<div class="modal-body">
		</div>
		<div class="modal-footer">
			<a href="#" onclick="closeModel('#modal-deactive-user')" class="btn danger">Close</a>
			<a href="#" onclick="activeUser()" class="btn success">submit</a>
		</div>
</div>
<div id="modal-active-user" class="modal hide fade">
		<div class="modal-header">
			<a href="#" class="close">&times;</a>
			<h3>De-Active User</h3>
		</div>
		<div class="modal-body">
		</div>
		<div class="modal-footer">
			<a href="#" onclick="closeModel('#modal-active-user')" class="btn danger">Close</a>
			<a href="#" onclick="deActiveUser()" class="btn success">submit</a>
		</div>
</div>

<script language="Javascript">

	function setInfoForActiveUser(url, name, userId){
		//alert("active form");
		jQuery("#modal-deactive-user").modal({
			show: true, 
            backdrop: 'static'
		})
		info = '<fmt:message key="user.active"/> : ' + name + '</p>' + 
			"<input type='hidden' id='urlActive' value='" + url + "'/>" +
			"<input type='hidden' id='userId' value='" + userId + "'/>";
			jQuery('#modal-deactive-user .modal-body').html(info);
	}

	function activeUser() {
		urlActive = jQuery('#modal-deactive-user input#urlActive').val();
		activeId = '#active' + jQuery('#modal-deactive-user input#userId').val();
		deactiveId = '#deactive' + jQuery('#modal-deactive-user input#userId').val();
		jQuery('#modal-deactive-user').modal('hide');
		jQuery.ajax({
			  url: urlActive,
			  context: document.body,
			  success: function(){
			   		jQuery(activeId).show();
			   		jQuery(deactiveId).hide();
			  }
			});
	}

	function setInfoForDeActiveUser(url, name, userId){
		jQuery("#modal-active-user").modal({
			show: true, 
            backdrop: 'static'
		})
		info = '<fmt:message key="user.deactive"/> : ' + name + '</p>' + 
			"<input type='hidden' id='urlDeActive' value='" + url + "'/>" +
			"<input type='hidden' id='userId' value='" + userId + "'/>";
			jQuery('#modal-active-user .modal-body').html(info);
	}

	function deActiveUser() {
		urlActive = jQuery('#modal-active-user input#urlDeActive').val();
		activeId = '#active' + jQuery('#modal-active-user input#userId').val();
		deactiveId = '#deactive' + jQuery('#modal-active-user input#userId').val();
		jQuery('#modal-active-user').modal('hide');
		jQuery.ajax({
			  url: urlActive,
			  context: document.body,
			  success: function(){
			   		jQuery(activeId).hide();
			   		jQuery(deactiveId).show();
			  }
			});
	}

	function closeModel(idModel){
		jQuery(idModel).modal({
			closeOnEscape: true
		})
	}
	
</script> 